﻿Imports System.Windows.Forms

Public Class dlgTempSensors

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub dlgTempSensors_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        updateValues()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        updateValues()

    End Sub

    Private Sub updateValues()
        'temp sensor addresses
        If DisplayInfo(DI_TS_HLT) <> "000000000000000000000000" Or DisplayInfo(DI_TS_HLT) = "[none]" Then
            btnScan0.Enabled = False
            btnClear0.Enabled = True
        Else
            btnScan0.Enabled = True
            btnClear0.Enabled = False
        End If
        If DisplayInfo(DI_TS_MASH) <> "000000000000000000000000" Or DisplayInfo(DI_TS_MASH) = "[none]" Then
            btnScan1.Enabled = False
            btnClear1.Enabled = True
        Else
            btnScan1.Enabled = True
            btnClear1.Enabled = False
        End If
        If DisplayInfo(DI_TS_KET) <> "000000000000000000000000" Or DisplayInfo(DI_TS_KET) = "[none]" Then
            btnScan2.Enabled = False
            btnClear2.Enabled = True
        Else
            btnScan2.Enabled = True
            btnClear2.Enabled = False
        End If
        If DisplayInfo(DI_TS_H2OIN) <> "000000000000000000000000" Or DisplayInfo(DI_TS_H2OIN) = "[none]" Then
            btnScan3.Enabled = False
            btnClear3.Enabled = True
        Else
            btnScan3.Enabled = True
            btnClear3.Enabled = False
        End If
        If DisplayInfo(DI_TS_H2OOUT) <> "000000000000000000000000" Or DisplayInfo(DI_TS_H2OOUT) = "[none]" Then
            btnScan4.Enabled = False
            btnClear4.Enabled = True
        Else
            btnScan4.Enabled = True
            btnClear4.Enabled = False
        End If
        If DisplayInfo(DI_TS_BEEROUT) <> "000000000000000000000000" Or DisplayInfo(DI_TS_BEEROUT) = "[none]" Then
            btnScan5.Enabled = False
            btnClear5.Enabled = True
        Else
            btnScan5.Enabled = True
            btnClear5.Enabled = False
        End If
        If DisplayInfo(DI_TS_AUX1) <> "000000000000000000000000" Or DisplayInfo(DI_TS_AUX1) = "[none]" Then
            btnScan6.Enabled = False
            btnClear6.Enabled = True
        Else
            btnScan6.Enabled = True
            btnClear6.Enabled = False
        End If
        If DisplayInfo(DI_TS_AUX2) <> "000000000000000000000000" Or DisplayInfo(DI_TS_AUX2) = "[none]" Then
            btnScan7.Enabled = False
            btnClear7.Enabled = True
        Else
            btnScan7.Enabled = True
            btnClear7.Enabled = False
        End If
        If DisplayInfo(DI_TS_AUX3) <> "000000000000000000000000" Or DisplayInfo(DI_TS_AUX3) = "[none]" Then
            btnScan8.Enabled = False
            btnClear8.Enabled = True
        Else
            btnScan8.Enabled = True
            btnClear8.Enabled = False
        End If
        tbHLTaddr.Text = DisplayInfo(DI_TS_HLT)
        tbMASHaddr.Text = DisplayInfo(DI_TS_MASH)
        tbKETaddr.Text = DisplayInfo(DI_TS_KET)
        tbH2OinAddr.Text = DisplayInfo(DI_TS_H2OIN)
        tbH2OoutAddr.Text = DisplayInfo(DI_TS_H2OOUT)
        tbBeerOutAddr.Text = DisplayInfo(DI_TS_BEEROUT)
        tbAux1addr.Text = DisplayInfo(DI_TS_AUX1)
        tbAux2addr.Text = DisplayInfo(DI_TS_AUX2)
        tbAux3addr.Text = DisplayInfo(DI_TS_AUX3)

        'temp values
        lblHLT.Text = DisplayInfo(DI_HLT_TEMP)
        lblMash.Text = DisplayInfo(DI_MASH_TEMP)
        lblKET.Text = DisplayInfo(DI_KET_TEMP)
        lblWaterIn.Text = DisplayInfo(DI_TEMP_H2O_IN)
        lblWaterOut.Text = DisplayInfo(DI_TEMP_H2O_OUT)
        lblBeerOut.Text = DisplayInfo(DI_TEMP_BEER)
        lblAux1.Text = DisplayInfo(DI_TEMP_AUX1)
        lblAux2.Text = DisplayInfo(DI_TEMP_AUX2)
        lblAux3.Text = DisplayInfo(DI_TEMP_AUX3)

    End Sub

    Private Sub btnClear0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear0.Click
        AddToTXstack("SET_TS+0+000+000+000+000+000+000+000+000-")
    End Sub

    Private Sub btnScan0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan0.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_0 = True
    End Sub

    Private Sub btnScan1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan1.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_1 = True

    End Sub

    Private Sub btnScan2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan2.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_2 = True

    End Sub

    Private Sub btnScan3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan3.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_3 = True

    End Sub

    Private Sub btnScan4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan4.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_4 = True

    End Sub

    Private Sub btnScan5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan5.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_5 = True

    End Sub

    Private Sub btnScan6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan6.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_6 = True

    End Sub

    Private Sub btnScan7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan7.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_7 = True

    End Sub

    Private Sub btnScan8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan8.Click
        'request sensor address from BT
        AddToTXstack("SCAN_TS-")
        'indicate which probe to assign next address to
        blnAssignTS_SCAN_to_8 = True

    End Sub

    Private Sub btnClear1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear1.Click
        AddToTXstack("SET_TS+1+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear2.Click
        AddToTXstack("SET_TS+2+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear3.Click
        AddToTXstack("SET_TS+3+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear4.Click
        AddToTXstack("SET_TS+4+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear5.Click
        AddToTXstack("SET_TS+5+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear6.Click
        AddToTXstack("SET_TS+6+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear7.Click
        AddToTXstack("SET_TS+7+000+000+000+000+000+000+000+000-")

    End Sub

    Private Sub btnClear8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear8.Click
        AddToTXstack("SET_TS+8+000+000+000+000+000+000+000+000-")

    End Sub
End Class
